package com.zhu.classfile.constant.base;

import com.zhu.classfile.constant.ConstantInfo;
import com.zhu.classfile.constant.ConstantPool;
import com.zhu.classfile.constant.ConstantTag;

import java.nio.ByteBuffer;

//CONSTANT_MethodHandle_info
public class ConstantMethodHandleInfo implements ConstantInfo {
    private final ConstantTag tag = ConstantTag.CONSTANT_MethodHandle;
    private final ConstantPool cp;
    private int referenceKind;
    private int referenceIndex;

    public ConstantMethodHandleInfo(ConstantPool cp) {
        this.cp = cp;
    }

    @Override
    public void readInfo(ByteBuffer reader) {
        referenceKind = Byte.toUnsignedInt(reader.get());
        referenceIndex = Short.toUnsignedInt(reader.getShort());
    }

    public int getReferenceKind() {
        return referenceKind;
    }

    public int getReferenceIndex() {
        return referenceIndex;
    }

    @Override
    public ConstantTag getTag() {
        return tag;
    }
}